package at.guigu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/booksTwo")
public class BookControllerTwo {

    @Autowired
    private Environment environment;

    @GetMapping("/{id}")
    public String getById(@PathVariable(value = "id") Integer id) {
        System.out.println("id===>" + id);
        System.out.println(environment.getProperty("name"));
        System.out.println(environment.getProperty("a.b.c"));
        System.out.println(environment.getProperty("a.b.arrayOne[0]"));
        System.out.println(environment.getProperty("e.arrayTwo[0]"));
        System.out.println("--------------------------------");
        System.out.println(environment.resolvePlaceholders("d的属性值为：${a.b.d}"));
        System.out.println("--------------------------------");
        System.out.println(environment.resolveRequiredPlaceholders("post的属性值为:${server.port}"));
        return "Hello SpringBoot!!!";
    }
}
